package com.admission.service;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;

import com.admission.dao.LogDao;
import com.admission.model.Log;

@Repository
@Transactional
public class LogManager {
	private LogDao logDao;

	public void save(Log entity) {
		logDao.save(entity);
	}

	public void delete(String ids) {
		for (String id : ids.split(",")) {
			logDao.delete(id);
		}
	}

	public Log getById(String id) {
		return logDao.findUniqueBy("id", id);
	}

	public Page<Log> getAll(Page<Log> page) {
		Criterion criterions = Restrictions.ne("inputBy", "penggege");
		Criterion criterions1 = Restrictions.ne("inputBy", "anonymousUser");
		return logDao.findPage(page,criterions,criterions1);
	}

	@Autowired
	public void setLogDao(LogDao logDao) {
		this.logDao = logDao;
	}

}
